<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=
    , initial-scale=1.0"
    />
    <title>Document</title>
  </head>
  <body>
    <script>
      function loadImg(url) {
        return new Promise((resolve, reject) => {
          const img = new Image();
          img.onload = function () {
            console.log("一张图片加载完成");
            resolve(img);
          };
          img.onerror = function () {
            reject(new Error("Could not load image at" + url));
          };
          img.src = url;
        });
      }
      loadImg();
    </script>
  </body>
</html>
